//------------------------------------------------------------------------------
#include "CMyCheckBox.h"
//------------------------------------------------------------------------------
CMyCheckBox::CMyCheckBox(QWidget *parent) : QCheckBox(parent), CChamp()
{
}
//------------------------------------------------------------------------------
QString CMyCheckBox::getValue(void)
{
	return (isChecked() ? "OUI" : "NON");
}
//------------------------------------------------------------------------------
void CMyCheckBox::setValue(QVariant value)
{
	setChecked(value.toString() == "OUI");
}
//------------------------------------------------------------------------------
void CMyCheckBox::setStateEnable(bool enable)
{
	if(_standaloneEnable)
	{
		setEnabled(enable);
	}
}
//------------------------------------------------------------------------------
void CMyCheckBox::setAttribut(EAttribut value)
{
	QString styleSheet="color: %1; font-weight: %2;";
	QString color="black;";
	QString weight="normal";
	
	_attribut=value;
	
	if(_attribut & atObligatoire)
	{
		color="#FF0000;";
		weight="bold";
	}
	
	if(_attribut & atObligatoireConditionel)
	{
		color="#0000FF;";
		weight="bold";
		setToolTip(getTextCondition());
	}
	
	setStyleSheet(styleSheet.arg(color).arg(weight));
}
//------------------------------------------------------------------------------
void CMyCheckBox::setTextCondition(QString value)
{
	_textCondition=value;
	if(getAttribut() & atObligatoireConditionel)
	{
		setToolTip(value);
	}
}
//------------------------------------------------------------------------------
void CMyCheckBox::keyPressEvent(QKeyEvent * event)
{
	if(event->key() == Qt::Key_F1)
	{
		emit invokeHelp(this);
	}
	QCheckBox::keyPressEvent(event);
}
//------------------------------------------------------------------------------

